package com.ht.dao;

import com.ht.bean.*;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

public interface KaoheDao {
    //考核id查询 模糊查询
    @Select({"<script>",
            "select kb.aduitModelId,kb.aduitName,kb.scores,dp.depName,kb.remark from aduitmodel kb,  dep dp  ",
            "<where>",
            "and kb.depid=dp.depid",
            "<if test=\"kb.aduitModelId!=null and kb.aduitModelId!=''\">",
            " and kb.aduitModelId=#{kb.aduitModelId}",
            "</if>",
            "<if test=\"dp.depid!=null and dp.depid!=''\">",
            " and dp.depid =#{dp.depid}",
            "</if>",
            "</where>",
            " limit #{startIndex},#{pageSize}",
            "</script>"})
    List<Map> kaohelist(@Param("startIndex") Integer startIndex, @Param("pageSize")Integer pageSize, @Param("kb") Aduitmodel aduitmodel, @Param("dp") Dep dep);


    //考核id查询 模糊查询的总页数
    @Select({"<script>",
            "select count(*) from aduitmodel kb,  dep dp ",
            "<where>",
            "and kb.depid=dp.depid",
            "<if test=\"kb.aduitModelId!=null and kb.aduitModelId!=''\">",
            " and kb.aduitModelId=#{kb.aduitModelId}",
            "</if>",
            "<if test=\"dp.depid!=null and dp.depid!=''\">",
            " and dp.depid =#{dp.depid}",
            "</if>",
            "</where>",
            "</script>"})
    public int kaohecount( @Param("kb") Aduitmodel aduitmodel, @Param("dp") Dep dep);


    //考核管理新增
    @Insert("insert into aduitmodel values(null,#{aduitName},#{scores},#{depid},#{remark})")
    public boolean kaoheadd(Aduitmodel aduitmodel);

    //考核管理删除
    @Delete("delete from aduitmodel where aduitModelId=#{aduitModelId}")
    public boolean kaohedel(String aduitModelId);


    //考核管理根据id查找对象
    @Select("select * from aduitmodel where aduitModelId=#{aduitModelId}")
    public Aduitmodel kaohesel(String aduitModelId);


    //考核管理修改
    @Update("update aduitmodel set aduitName=#{aduitName},scores=#{scores},depid=#{depid},remark=#{remark} where aduitModelId=#{aduitModelId}")
    public boolean kaoheupd(Aduitmodel aduitmodel);



    ///员工考核↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------++++++++++++--------------------------------------------------------------+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    //员工考核id查询 模糊查询
    @Select({"<script>",
            "select al.aduitLogId,a.aduitName,ep.empName,al.scores,al.auditDate,al.remark,al.auditPerson,al.image from aduitlog al , emp ep , aduitmodel a ",
            "<where>",
            " al.aduitModelId=a.aduitModelId and al.empId=ep.empId",
            "<if test=\"al.aduitLogId!=null and al.aduitLogId!=''\">",
            " and al.aduitLogId=#{al.aduitLogId}",
            "</if>",
            "<if test=\"ep.empId!=null and ep.empId!=''\">",
            " and ep.empId=#{ep.empId}",
            "</if>",
            "</where>",
            " limit #{startIndex},#{pageSize}",
            "</script>"})
    List<Map> ygkhlist(@Param("startIndex") Integer startIndex, @Param("pageSize")Integer pageSize, @Param("al") Aduitlog aduitlog, @Param("ep") Emp emp);

    //员工考核id查询 模糊查询的总页数
    @Select({"<script>",
            "select count(*) from aduitlog al , emp ep , aduitmodel a ",
            "<where>",
            " al.aduitModelId=a.aduitModelId and al.empId=ep.empId",
            "<if test=\"al.aduitLogId!=null and al.aduitLogId!=''\">",
            " and al.aduitLogId=#{al.aduitLogId}",
            "</if>",
            "<if test=\"ep.empId!=null and ep.empId!=''\">",
            " and ep.empId=#{ep.empId}",
            "</if>",
            "</where>",
            "</script>"})
    public int ygkhcount(@Param("al") Aduitlog aduitlog, @Param("ep") Emp emp);

    //员工考核新增
    @Insert("insert into aduitlog values(null,#{aduitModelId},#{empId},#{scores},now(),#{remark},#{auditPerson},#{image})")
    public boolean ygkhadd(Aduitlog aduitlog);

    //员工考核删除
    @Delete("delete from aduitlog where aduitLogId=#{aduitLogId}")
    public boolean ygkhdel(String aduitLogId);



    //查询员工表
    @Select("select * from emp")
    List<Emp>ygkhemp();


    //查询员工表
    @Select("select * from aduitmodel")
    List<Aduitmodel>ygkhkhzb();


    //查询部门表
    @Select("select * from dep")
    List<Dep>ygkhdep();






    //员工考核根据id查找对象
    @Select("select * from aduitlog where aduitLogId=#{aduitLogId}")
    public Aduitlog ygkhsel(String aduitLogId);


    //员工考核修改
    @Update("update aduitlog set aduitModelId=#{aduitModelId},empId=#{empId},scores=#{scores},auditDate=now(),remark=#{remark},auditPerson=#{auditPerson},image=#{image} where aduitLogId=#{aduitLogId}")
    public boolean ygkhupd(Aduitlog aduitlog);




    //教师考核////////////////////////////////////////////////////////////////////////////////////////////////////////////////////





    //教师考评模糊查询
    @Select({"<script>",
            "select j.jskhid,k.kpnr,sc.className,j.fenshu,e.empName,j.time,j.jtime from jskh j,kpnr k,studentclass sc,emp e",
            "<where>",
            "j.kpnr=k.id and j.classid=sc.classId and j.empid=e.empId",
            "<if test=\"j.classid!=null and j.classid!=''\">",
            " and j.classid=#{j.classid}",
            "</if>",
            "</where>",
            " ORDER BY fenshu+0 limit #{startIndex},#{pageSize}",
            "</script>"})
    List<Map> jsklist(@Param("startIndex") Integer startIndex, @Param("pageSize")Integer pageSize,@Param("j") Jskh jskh);


    //教师考评分页
    @Select({"<script>",
            "select count(*) from jskh j,kpnr k,studentclass sc,emp e ",
            "<where>",
            "j.kpnr=k.id and j.classid=sc.classId and j.empid=e.empId",
            "<if test=\"j.classid!=null and j.classid!=''\">",
            " and j.classid=#{j.classid}",
            "</if>",
            "</where>",
            "</script>"})
    public int jskcount(@Param("j") Jskh jskh);








    //学生考评模糊查询
    @Select({"<script>",
            "select j.jskhid,k.kpnr,sc.className,j.fenshu,e.empName,j.time,j.jtime from jskh j,kpnr k,studentclass sc,emp e",
            "<where>",
            "j.kpnr=k.id and j.classid=sc.classId and j.empid=e.empId and j.classid = #{j.classid}",
            "<if test=\"j.classid!=null and j.classid!=''\">",
            " and j.classid=#{j.classid}",
            "</if>",
            "</where>",
            " limit #{startIndex},#{pageSize}",
            "</script>"})
    List<Map> jskhlist(@Param("startIndex") Integer startIndex, @Param("pageSize")Integer pageSize,@Param("j") Jskh jskh);


    //学生考评分页
    @Select({"<script>",
            "select count(*) from jskh j,kpnr k,studentclass sc,emp e ",
            "<where>",
            "j.kpnr=k.id and j.classid=sc.classId and j.empid=e.empId and j.classid = #{j.classid}",
            "<if test=\"j.classid!=null and j.classid!=''\">",
            " and j.classid=#{j.classid}",
            "</if>",
            "</where>",
            "</script>"})
    public int jskhcount(@Param("j") Jskh jskh);


    //教师考评查询
    @Select("select * from kpnr")
    List<Kpnr> kpnrlist();

    //新增考评
//    @Insert("insert into kpnr values(null,)")


    //考核管理新增
    @Insert("insert into jskh values(null,#{kpnr},#{classid},#{fenshu},#{empid},now(),#{jtime})")
    public boolean jskhadd(Jskh jskh);



    //班级表查询
    @Select("select * from studentclass")
    List<Studentclass>sclist();

    //员工表查询
    @Select("select * from emp")
    List<Emp>emplist();

    //员工表查询
    @Select("select emp.depId from emp where empId=#{empId}")
    Integer ygcx(Integer empId);

    //教师考评删除
    @Delete("delete from jskh where jskhid=#{jskhid}")
    public boolean jskhdel(String jskhid);



    //**********************123456


//    学生端评价
    @Update("update jskh set fenshu=#{fenshu},jtime=now() where jskhid=#{jskhid}")
    public boolean xsupd(Jskh jskh);


    //学生端评价根据id查找对象
    @Select("select * from jskh where jskhid=#{jskhid}")
    public Jskh xssel(String jskhid);





}
